package com.epic.followup.conf;


import com.epic.followup.interceptor.WechatPatientInterceptor;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WechatLoginConfig implements WebMvcConfigurer {

    /**
     * 不需要登录拦截的url
     */
    private static final String[] notLoginInterceptPaths = {"/static/**",
            "/wechat/patient/getOpendId", "/wechat/patient/autoLogin",
           }; // 微信登录

    private WechatPatientInterceptor getloginInterceptor(){
        return new WechatPatientInterceptor();
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {

        InterceptorRegistration addInterceptor = registry.addInterceptor(getloginInterceptor());
        addInterceptor.excludePathPatterns(notLoginInterceptPaths);
        // 动态路径拦截
        addInterceptor.addPathPatterns("/wechat/**");
         //静态资源拦截 暂无
         //addInterceptor.addPathPatterns("/wechat/**");

    }

}
